package com.mxl.common.rule;

public abstract class AbstractRule extends AbstractComponent {

	public void setForwardStep(AbstractComponent forwardStep) {
		this.forwardStep = forwardStep;
	}

	public void setBackStep(AbstractComponent backStep) {
		this.backStep = backStep;
	}

	public void execute(Object arg) throws Exception {
		boolean outcome = makeDecision(arg);
		if (outcome)
			forwardStep.execute(arg);
		else
			backStep.execute(arg);
	}

	protected abstract boolean makeDecision(Object obj) throws Exception;

	private AbstractComponent forwardStep;
	private AbstractComponent backStep;
}
